package com.jackyzgy.test.threadGroup;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;

public class MyExecutor extends Thread {
	private int index;

	public MyExecutor(int i) {
		this.index = i;
	}

	public void run() {
		try {
			System.out.println("[" + this.index + "] start....");
			Thread.sleep((int) (Math.random() * 10000));
			System.out.println("[" + this.index + "] end.");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String args[]) {
//		ExecutorService service = Executors.newFixedThreadPool(6);
//		for (int i = 0; i < 10; i++) {
//			service.execute(new MyExecutor(i));
//			// service.submit(new MyExecutor(i));
//		}
//		System.out.println("submit finish");
//		service.shutdown();

		Thread thread = Executors.defaultThreadFactory().newThread(
				new Runnable() {

					public void run() {
						// TODO Auto-generated method stub
						System.out.println(">>>>>>>>>>>>>>>>>>>>>>> ");
					}
				});

		thread.start();
	}
}